package com.tcs.zookeeper.bean;

import java.io.Serializable;

import org.apache.curator.RetryPolicy;
import org.apache.curator.framework.CuratorFramework;
import org.apache.curator.framework.CuratorFrameworkFactory;

public class CuratorBean implements Serializable {
	
	private static final long serialVersionUID = 1L;

	private String zookeeperIps;
	
	private Integer sessionTimeoutMs;
	
	private RetryPolicy retryPolicy;
	
	private CuratorFramework cf;

	public String getZookeeperIps() {
		return zookeeperIps;
	}

	public void setZookeeperIps(String zookeeperIps) {
		this.zookeeperIps = zookeeperIps;
	}

	public Integer getSessionTimeoutMs() {
		return sessionTimeoutMs;
	}

	public void setSessionTimeoutMs(Integer sessionTimeoutMs) {
		this.sessionTimeoutMs = sessionTimeoutMs;
	}

	public RetryPolicy getRetryPolicy() {
		return retryPolicy;
	}

	public void setRetryPolicy(RetryPolicy retryPolicy) {
		this.retryPolicy = retryPolicy;
	}
	
	public CuratorFramework getCuratorFramework() {
		cf = CuratorFrameworkFactory.builder().connectString(zookeeperIps).sessionTimeoutMs(sessionTimeoutMs)
				.retryPolicy(retryPolicy).build();
		return cf;
	}
	
	public CuratorFramework getCuratorFrameworkAndStart() {
		cf = CuratorFrameworkFactory.builder().connectString(zookeeperIps).sessionTimeoutMs(sessionTimeoutMs)
				.retryPolicy(retryPolicy).build();
		cf.start();
		return cf;
	}
}